﻿//创建时间: 2010-10-11
//创建作者: 李 城
//功能说明: 系统参数 管理 
//最后修改: 2010-10-11
using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using TRPOP.Common;
using TRPOP.CMS.Web.UI;


using TRPOP.CMS.Business;
using TRPOP.CMS.Model;
using System.Collections;

namespace TRPOP.CMS.Web.Admin
{
    public partial class Param_list : BaseAdmin
    {
        #region 当前页面权限验证
        protected override void SubPageInit()
        {
            base.m_SubPagePermission = Plugin.PermissionKeys.PermissionEnum.SystemManage_Other;
        }
        #endregion


        #region 页面变量
        protected string m_strTitle = "";
        protected int m_cid = 0;
        ParamTypeManage oParamTypeManage = new ParamTypeManage();
        #endregion

        #region 页面事件
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                InitRequestViewState("cid");
                LoadBase();
            }
        }
        protected void lbtnDelete_Click(object sender, EventArgs e)
        {
            LinkButton lbtn = (LinkButton)sender;
            ArrayList oArrayKey = new ArrayList();
            oArrayKey.Add(lbtn.CommandArgument);
            int.TryParse(GetRequestViewState("cid"), out m_cid);
            ParamTypeInfo oParamTypeInfo = new ParamTypeInfo();
            oParamTypeInfo = oParamTypeManage.GetInfoById(m_cid);

            SubmitAlertDelete(SYSConfig.DelConfigValue(oArrayKey, oParamTypeInfo.KeyWord));
            LoadBase();
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            string Ids = RequestHelper.RequestString("delid");
            if (Ids.Length == 0)
            {
                Alert("请先选中要删除的信息");
                LoadBase();
                return;
            }
            ArrayList oArrayKey = new ArrayList();
            foreach (string temp in Ids.Split(','))
            {
                oArrayKey.Add(temp);
            }
            int.TryParse(GetRequestViewState("cid"), out m_cid);
            ParamTypeInfo oParamTypeInfo = new ParamTypeInfo();
            oParamTypeInfo = oParamTypeManage.GetInfoById(m_cid);
            SubmitAlertDelete(SYSConfig.DelConfigValue(oArrayKey, oParamTypeInfo.KeyWord));
            base.SaveLog(Plugin.LogKeys.OperObject.TemplateOper, Plugin.LogKeys.OperResult.EditSubmit);
            LoadBase();
        }
        #endregion

        #region 页面方法
        public void LoadBase()
        {
            int.TryParse(GetRequestViewState("cid"), out m_cid);
            if (m_cid > 0)
            {
                ParamTypeInfo oParamTypeInfo = new ParamTypeInfo();
                oParamTypeInfo = oParamTypeManage.GetInfoById(m_cid);
                if (oParamTypeInfo == null)
                {
                    return;
                }
                else
                {
                    m_strTitle = oParamTypeInfo.Name;
                    rptList.DataSource =  SYSConfig.GetDataSource(oParamTypeInfo.KeyWord, "//items");
                    rptList.DataBind();
                }
            }
        }
        #endregion
    }
}
